import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xiaomishop/app/modules/gooddetail/views/gooddetail_view.dart';
import 'package:xiaomishop/app/net/HttManager.dart';
import 'package:xiaomishop/app/service/MyScreenExtention.dart';

import '../controllers/gooddetail_controller.dart';

class FirstGoodView extends GetView {
  final BuildContext parentContext;

  FirstGoodView({required this.parentContext, Key? key}) : super(key: key);
  GooddetailController controller = Get.find();

  @override
  Widget build(BuildContext context) {
    return Obx(() => Container(
        child: controller.detail.value.sid == null
            ? Container(
                width: 1080.ww,
                height: 1920.hh,
                alignment: Alignment.center,
                child: Container(child: CircularProgressIndicator()))
            : Container(
                key: controller.key1,
                width: double.infinity,
                child: Column(
                  children: [
                    Container(
                      alignment: Alignment.center,
                        height: 680.hh,
                        child: Image.network(
                            HttManager.instance
                                .urlFormat(controller.detail.value.pic),
                            fit: BoxFit.fill)),
                    Container(
                        padding: EdgeInsets.fromLTRB(10.ww, 20.hh, 20.ww, 0),
                        alignment: Alignment.topLeft,
                        child: Text(controller.detail.value.title!,
                            style: TextStyle(fontSize: 46.ss))),
                    Container(
                        padding: EdgeInsets.fromLTRB(10.ww, 10.hh, 20.ww, 0),
                        alignment: Alignment.topLeft,
                        child: Text(controller.detail.value.subTitle!,
                            style: TextStyle(fontSize: 36.ss))),
                    Container(
                        margin: EdgeInsets.fromLTRB(10.ww, 0, 10.ww, 0),
                        alignment: Alignment.center,
                        height: 80.hh,
                        width: double.infinity,
                        child: Stack(
                          children: [
                            Positioned(
                                left: 0,
                                top: 0,
                                bottom: 0,
                                child: Row(children: [
                                  Text("价格："),
                                  Text("￥${controller.detail.value.price!}",
                                      style: TextStyle(
                                          fontSize: 60.ss, color: Colors.red))
                                ])),
                            Positioned(
                                right: 0,
                                top: 0,
                                bottom: 0,
                                child: Row(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.center,
                                    children: [
                                      Align(
                                        child: Text("原价：",
                                            style: TextStyle(
                                                color: Colors.black38)),
                                        alignment: Alignment.center,
                                      ),
                                      Align(
                                        child: Text(
                                            "￥${controller.detail.value.oldPrice!}",
                                            style: TextStyle(
                                                color: Colors.black38,
                                                decoration: TextDecoration
                                                    .lineThrough)),
                                        alignment: Alignment.center,
                                      )
                                    ]))
                          ],
                        )),
                    InkWell(
                        child: Container(
                            margin: EdgeInsets.fromLTRB(10.ww, 0, 10.ww, 0),
                            alignment: Alignment.center,
                            height: 80.hh,
                            width: double.infinity,
                            child: Stack(
                              children: [
                                Positioned(
                                    left: 0,
                                    top: 0,
                                    bottom: 0,
                                    child: Row(children: [
                                      Text("已选："),
                                      Text("115，黑色，XL，1件",
                                          style: TextStyle(color: Colors.black))
                                    ])),
                                Positioned(
                                    right: 0,
                                    top: 0,
                                    bottom: 0,
                                    child: Icon(
                                        Icons.keyboard_arrow_right_sharp,
                                        color: Colors.black38))
                              ],
                            )),
                        onTap: () {
                          //获取父view的实例，调用父view的函数
                          context
                              .findAncestorWidgetOfExactType<GooddetailView>()!
                              .shoGoodBottomSheet(parentContext);
                        }),
                    Container(
                        margin: EdgeInsets.fromLTRB(10.ww, 0, 10.ww, 0),
                        alignment: Alignment.center,
                        height: 80.hh,
                        width: double.infinity,
                        child: Stack(
                          children: [
                            Positioned(
                                left: 0,
                                top: 0,
                                bottom: 0,
                                child: Row(children: [
                                  Text("门店："),
                                  Text("小米之家",
                                      style: TextStyle(color: Colors.black))
                                ])),
                            Positioned(
                                right: 0,
                                top: 0,
                                bottom: 0,
                                child: Icon(Icons.keyboard_arrow_right_sharp,
                                    color: Colors.black38))
                          ],
                        )),
                    Container(
                        margin: EdgeInsets.fromLTRB(10.ww, 0, 10.ww, 0),
                        alignment: Alignment.center,
                        height: 120.hh,
                        width: double.infinity,
                        child: Stack(
                          children: [
                            Positioned(
                                left: 0,
                                top: 0,
                                bottom: 0,
                                child: Row(children: [
                                  Text("服务："),
                                  Container(
                                    width: 800.ww,
                                    height: double.infinity,
                                    child: Image.asset(
                                        "assets/images/service.png"),
                                  )
                                ])),
                            Positioned(
                                right: 0,
                                top: 0,
                                bottom: 0,
                                child: Icon(Icons.keyboard_arrow_right_sharp,
                                    color: Colors.black38))
                          ],
                        ))
                  ],
                ),
              )));
  }
}
